﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace WeiXinPF.WeiXinComm
{
    /// <summary>
    /// 微信格式的返回值
    /// errcode=0时为操作成功
    /// errmsg为消息
    /// </summary>
    public class WeiXinResult
    {
        public WeiXinResult()
        {
            ErrorCode = "0";
            ErrorMessage = "ok";
        }

        public WeiXinResult(string errorCode, string errorMessage)
            : this()
        {
            this.ErrorCode = errorCode;
            this.ErrorMessage = errorMessage;
        }

        public WeiXinResult(string errorCode, string errorMessage, dynamic data)
            : this(errorCode, errorMessage)
        {
            this.Data = data;
        }
        /// <summary>
        /// 返回编码
        /// </summary>
        [JsonProperty(PropertyName = "errcode")]
        public string ErrorCode { get; set; }
        /// <summary>
        /// 返回消息
        /// </summary>
        [JsonProperty(PropertyName = "errmsg")]
        public string ErrorMessage { get; set; }
        /// <summary>
        /// 返回数据
        /// </summary>
        [JsonProperty(PropertyName = "data")]
        public dynamic Data { get; set; }

        public override string ToString()
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(this);
        }
    }
}
